package vistas.clientes;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JButton;

import javax.swing.JComboBox;
import javax.swing.JLabel;

import javax.swing.JTextArea;

import javax.swing.WindowConstants;

import javax.swing.SwingUtilities;

import app.Odv;




/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class BajaFrame extends javax.swing.JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JLabel jLabel1;
	private JLabel jLabel2;
	private JLabel jLabel3;
	private JLabel jLabel4;
	private JButton jButtonNO;
	private JButton jButtonSI;
	private JTextArea jTextArea1;
	private JComboBox jComboBox1;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				BajaFrame inst = new BajaFrame();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public BajaFrame() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1);
				jLabel1.setText("INGRESE EL NUMERO");
				jLabel1.setBounds(12, 36, 134, 16);
			}
			{
				jLabel2 = new JLabel();
				getContentPane().add(jLabel2);
				jLabel2.setText("DE");
				jLabel2.setBounds(42, 58, 32, 16);
			}
			{
				jLabel3 = new JLabel();
				getContentPane().add(jLabel3);
				jLabel3.setText("CLIENTE");
				jLabel3.setBounds(29, 80, 60, 16);
			}
			{
				
				
				Odv s= Odv.getinstancia();
				List<String> lista = s.listaId();
				
				
				jComboBox1 = new JComboBox();
				getContentPane().add(jComboBox1);
				
				
				for(String i : lista)
					jComboBox1.addItem(i);
				
				
				
				
				jComboBox1.setBounds(202, 55, 90, 23);
				jComboBox1.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out.println("jComboBox1.actionPerformed, event="+evt);
						Odv s= Odv.getinstancia();
						
						String i=(String) jComboBox1.getSelectedItem();
					
						String cliente = s.imprimirCliente(i);
			
						jTextArea1.setText(cliente);
						
						
					}
				});
			}
			{
				jTextArea1 = new JTextArea();
				getContentPane().add(jTextArea1);
				jTextArea1.setBounds(0, 117, 384, 110);
			}
			{
				jLabel4 = new JLabel();
				getContentPane().add(jLabel4);
				jLabel4.setText("DESEA DAR DE BAJA ?");
				jLabel4.setBounds(12, 257, 164, 16);
			}
			{
				jButtonSI = new JButton();
				getContentPane().add(jButtonSI);
				jButtonSI.setText("SI");
				jButtonSI.setBounds(160, 252, 53, 31);
				jButtonSI.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out.println("jButtonSI.actionPerformed, event="+evt);
						
						Odv s= Odv.getinstancia();
						s.eliminarCliente((String) jComboBox1.getSelectedItem());
						BajaCorrecta v= new BajaCorrecta();
						v.setVisible(true);
						v.setLocationRelativeTo(null);
						
						jComboBox1.removeItem(jComboBox1.getSelectedItem());
						jTextArea1.setText("");
						
						
					}
				});
			}
			{
				jButtonNO = new JButton();
				getContentPane().add(jButtonNO);
				jButtonNO.setText("NO");
				jButtonNO.setBounds(239, 250, 53, 33);
				jButtonNO.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out.println("jButtonNO.actionPerformed, event="+evt);
						jTextArea1.setText("");
						dispose();
					}
				});
			}
			{
				
				
				
			}
			pack();
			this.setSize(400, 344);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
